package com.xcj.springai.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xcj.springai.entity.ChatConversationEntity;
import com.xcj.springai.mapper.ChatConversationMapper;
import com.xcj.springai.service.ChatConversationService;
import com.xcj.springai.vo.ChatConversationVo;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
@RequiredArgsConstructor
public class ChatConversationServiceImpl extends ServiceImpl<ChatConversationMapper, ChatConversationEntity> implements ChatConversationService {

    @Override
    public List<ChatConversationVo> getChatConversationList(Long userId) {
        List<ChatConversationEntity> list = list(new LambdaQueryWrapper<ChatConversationEntity>().eq(ChatConversationEntity::getUserId, userId).orderByDesc(ChatConversationEntity::getCreateTime));
        return list.stream().map(v -> {
            ChatConversationVo vo = new ChatConversationVo();
            vo.setConversationId(v.getId());
            vo.setTitle(v.getTitle());
            vo.setCreateTime(v.getCreateTime());
            return vo;
        }).toList();

    }

}



